<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :keyboard="false"
    :forceRender="true"
    v-bind:prefixNo="prefixNo"
    switchHelp
    switchFullscreen
    @cancel="handleCancel"
    :id="prefixNo"
    style="top:20px;height: 95%;">
    <template slot="footer">
      <a-button @click="handleCancel">{{ $t('button.cancel') }}</a-button>
      <a-button v-if="billPrintFlag" @click="handlePrint('销售订单')">{{ $t('button.sanlianPrintPreview') }}</a-button>
      <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">
        {{ $t('button.saveAndSubmit') }}
      </a-button>
      <a-button type="primary" :loading="confirmLoading" @click="handleOk">{{ $t('button.save') }}</a-button>
      <!--发起多级审核-->
      <!--      <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">{{$t('button.startProcess')}}</a-button>-->
    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row class="form-row" :gutter="24">
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.customer')" data-step="1"
                         :data-title="$t('search.customer')"
                         :data-intro="$t('intro.customerSelection')">
              <a-select :placeholder="$t('placeholder.pleaseSelectCustomer')"
                        v-decorator="[ 'organId', validatorRules.organId ]"
                        :dropdownMatchSelectWidth="false" showSearch optionFilterProp="children"
                        @change="handleOrganChange">
                <div slot="dropdownRender" slot-scope="menu">
                  <v-nodes :vnodes="menu" />
                  <a-divider style="margin: 4px 0;" />
                  <div v-if="isTenant" style="padding: 4px 8px; cursor: pointer;" @mousedown="e => e.preventDefault()"
                       @click="addCustomer">
                    <a-icon type="plus"/>
                    {{ $t('button.addCustomer') }}
                  </div>
                </div>
                <a-select-option v-for="(item,index) in cusList" :key="index" :value="item.id">
                  {{ item.supplier }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.billDate')">
              <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" :disabled="true"
                      :readOnly="true"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.billNumber')" data-step="2"
                         :data-title="$t('search.billNumber')"
            >
              <a-input :placeholder="$t('placeholder.pleaseInputBillNumber')" v-decorator.trim="[ 'number' ]" />
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.salesMan')" data-step="3"
                         :data-title="$t('search.salesMan')"
                         :data-intro="$t('intro.salesMan')">
              <a-select :placeholder="$t('placeholder.pleaseSelectSalesMan')"
                        v-model="personList.value"
                        optionFilterProp="children">
                <a-select-option v-for="(item, index) in personList.options" :key="item.value || item.id || index"
                                 :value="item.value || item.id">
                  {{ item.text || item.label || item.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.linkBill1')"
                         :data-title="$t('search.linkBill1')">
              <a-input-search :placeholder="$t('placeholder.pleaseSelectLinkBill1')" v-decorator="[ 'linkNumber' ]"
                              @search="onSearchLinkNumber"
                              :readOnly="true"/>
            </a-form-item>
          </a-col>

          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.poNo')"
                         :data-title="$t('search.poNo')">
              <a-input v-decorator.trim="[ 'pono' ]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <j-editable-table id="billModal"
                          :ref="refKeys[0]"
                          :loading="materialTable.loading"
                          :columns="materialTable.columns"
                          :dataSource="materialTable.dataSource"
                          :minWidth="minWidth"
                          :maxHeight="300"
                          :rowNumber="false"
                          :rowSelection="true"
                          :actionButton="true"
                          :dragSortAndNumber="true"
                          @valueChange="onValueChange"
                          @added="onAdded"
                          @deleted="onDeleted">
          <template #buttonAfter>
            <a-row :gutter="24" style="float:left;padding-bottom: 5px;" data-step="4"
                   :data-title="$t('button.scanEnter')"
                   :data-intro="$t('placeholder.scanEnter')">
              <a-col v-if="scanStatus" :md="6" :sm="24">
                <a-button @click="scanEnter">{{ $t('button.scanEnter') }}</a-button>
              </a-col>
              <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 8px 0 12px">
                <a-input :placeholder="$t('placeholder.pleaseInputScanBarCode')" v-model="scanBarCode"
                         @pressEnter="scanPressEnter"
                         ref="scanBarCode"/>
              </a-col>
              <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
                <a-button @click="stopScan">{{ $t('button.stopScan') }}</a-button>
              </a-col>
            </a-row>
            <a-row :gutter="24" style="float:left;padding-bottom: 5px;">
              <a-col :md="24" :sm="24">
                <a-button style="margin-left: 8px" @click="handleHistoryBillList">
                  <a-icon type="history"/>
                  {{ $t('button.historyBill') }}
                </a-button>
              </a-col>
            </a-row>
            <a-row :gutter="24" style="float:left;padding-bottom: 5px;padding-left:20px;">
              <a-button icon="import" @click="onImport(prefixNo)">{{ $t('button.importDetail') }}</a-button>
            </a-row>
          </template>
          <template #depotBatchSet>
            <a-icon type="down" @click="handleBatchSetDepot"/>
          </template>
          <template #depotAdd>
            <a-divider v-if="isTenant" style="margin: 4px 0;"/>
            <div v-if="isTenant" style="padding: 4px 8px; cursor: pointer;" @click="addDepot">
              <a-icon type="plus"/>
              {{ $t('button.addDepot') }}
            </div>
          </template>
        </j-editable-table>


        <a-row class="form-row" :gutter="24">
          <a-col :lg="24" :md="24" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="{xs: { span: 24 },sm: { span: 24 }}" label="">
              <a-textarea :rows="1" :placeholder="$t('placeholder.pleaseInputRemark')" v-decorator="[ 'remark' ]"
                          style="margin-top:8px;" />
            </a-form-item>
          </a-col>
        </a-row>

        <a-row class="form-row" :gutter="24">
          <a-col :lg="6" :md="12" :sm="24">
            <!--税率 %-->
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.saleTaxMoney')"
                         :data-title="$t('search.saleTaxMoney')"
            >
              <a-input v-decorator.trim="[ 'taxMoney' ]" @change="onChangeSaleTaxMoney" suffix="%"/>
            </a-form-item>
          </a-col>

          <a-col :lg="6" :md="12" :sm="24">
            <!--            优惠率-->
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.discount')" data-step="5"
                         :data-title="$t('search.discount')"
                         :data-intro="$t('placeholder.pleaseInputDiscountIntro')">
              <a-input style="width:185px;" :placeholder="$t('placeholder.pleaseInputDiscount')"
                       @change="onSaleChangeDiscount"
                       v-decorator.trim="[ 'discount' ]" suffix="%"/>
              <!--                       @change="onChangeDiscount"-->
            </a-form-item>
          </a-col>
          <!--          discountMoney1 收款优惠金额-->
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.discountMoney1')"
                         data-step="6"
                         :data-title="$t('search.discountMoney1')"
                         :data-intro="$t('intro.discountMoney')">
              <a-input :placeholder="$t('placeholder.pleaseInputDiscountMoney')"
                       v-decorator.trim="[ 'discountMoney' ]"/>
              <!--                       @change="onChangeDiscountMoney"-->
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <!--            优惠后金额-->
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.discountLastMoney')"
                         data-step="7"
                         :data-title="$t('search.discountLastMoney')"
                         :data-intro="$t('intro.discountLastMoney')">
              <a-input :placeholder="$t('placeholder.pleaseInputDiscountLastMoney')"
                       v-decorator.trim="[ 'discountLastMoney' ]" readOnly/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24"></a-col>
        </a-row>

        <a-row class="form-row" :gutter="24">
          <a-col :lg="6" :md="12" :sm="24">
            <!--税额 %-->
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.taxValue')"
                         :data-title="$t('search.taxValue')"
            >
              <a-input v-decorator.trim="[ 'taxValue' ]"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.accountName1')" data-step="8"
                         :data-title="$t('search.accountName1')"
                         :data-intro="$t('intro.selectMultipleAccounts')">
              <a-select style="width:185px;" :placeholder="$t('placeholder.pleaseSelectAccount')"
                        v-decorator="[ 'accountId' ]"
                        :dropdownMatchSelectWidth="false" allowClear @select="selectAccount">
                <div slot="dropdownRender" slot-scope="menu">
                  <v-nodes :vnodes="menu" />
                  <a-divider style="margin: 4px 0;" />
                  <div v-if="isTenant" style="padding: 4px 8px; cursor: pointer;"
                       @mousedown="e => e.preventDefault()" @click="addAccount">
                    <a-icon type="plus"/>
                    {{ $t('button.addAccount') }}
                  </div>
                </div>
                <a-select-option v-for="(item,index) in accountList" :key="index" :value="item.id">
                  {{ item.name }}
                </a-select-option>
              </a-select>
              <a-tooltip :title="$t('title.manyAccountDetail')">
                <a-button type="default" icon="folder" style="margin-left: 8px;" size="small"
                          v-show="manyAccountBtnStatus" @click="handleManyAccount"/>
              </a-tooltip>
            </a-form-item>
          </a-col>
          <!--          收取订金-->
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.receiveDeposit')"
                         data-step="9"
                         :data-title="$t('search.receiveDeposit')"
                         :data-intro="$t('intro.receiveDeposit')">
              <a-input :placeholder="$t('placeholder.pleaseInputReceiveDeposit')"
                       v-decorator.trim="[ 'changeAmount', validatorRules.price ]"
                       @change="onChangeChangeAmount"/>
            </a-form-item>
          </a-col>

          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.payType1')" data-step="3"
                         :data-title="$t('search.payType1')"
                         :data-intro="$t('search.payType1')">
              <a-select :placeholder="$t('placeholder.pleaseSelectPayType')"
                        v-model="payTypeList.value"
                        optionFilterProp="children">
                <a-select-option v-for="(item, index) in payTypeList.options" :key="item.value || item.id || index"
                                 :value="item.value || item.id">
                  {{ item.text || item.label || item.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row class="form-row" :gutter="24">
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('search.billAttachment')"
                         data-step="10" :data-title="$t('search.billAttachment')"
                         :data-intro="$t('placeholder.billAttachmentIntro')">
              <j-upload v-model="fileList" bizPath="bill"></j-upload>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
    <many-account-modal ref="manyAccountModalForm" @ok="manyAccountModalFormOk"></many-account-modal>
    <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk"></import-item-modal>
    <customer-modal ref="customerModalForm" @ok="customerModalFormOk"></customer-modal>
    <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
    <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
    <history-bill-list ref="historyBillListModalForm"></history-bill-list>
    <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
    <bill-print-iframe ref="modalPrint"></bill-print-iframe>
    <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
    <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  </j-modal>
</template>
<script>
import pick from 'lodash.pick'
import ManyAccountModal from '../dialog/ManyAccountModal'
import ImportItemModal from '../dialog/ImportItemModal'
import CustomerModal from '../../system/modules/CustomerModal'
import AccountModal from '../../system/modules/AccountModal'
import HistoryBillList from '../dialog/HistoryBillList'
import WorkflowIframe from '@/components/tools/WorkflowIframe'
import BillPrintIframe from '../dialog/BillPrintIframe'
import {FormTypes} from '@/utils/JEditableTableUtil'
import {JEditableTableMixin} from '@/mixins/JEditableTableMixin'
import {BillModalMixin} from '../mixins/BillModalMixin'
import {getMpListShort, handleIntroJs} from '@/utils/util'
import JSelectMultiple from '@/components/jeecg/JSelectMultiple'
import JUpload from '@/components/jeecg/JUpload'
import JDate from '@/components/jeecg/JDate'
import Vue from 'vue'
import DepotModal from '@views/system/modules/DepotModal.vue'
import BatchSetDepot from '@views/bill/dialog/BatchSetDepot.vue'
import LinkBillList from '@views/bill/dialog/LinkBillList.vue'

export default {
  name: 'SaleOrderModal',
  mixins: [JEditableTableMixin, BillModalMixin],
  components: {
    LinkBillList,
    BatchSetDepot,
    DepotModal,
    ManyAccountModal,
    ImportItemModal,
    CustomerModal,
    AccountModal,
    HistoryBillList,
    WorkflowIframe,
    BillPrintIframe,
    JUpload,
    JDate,
    JSelectMultiple,
    VNodes: {
      functional: true,
      render: (h, ctx) => ctx.props.vnodes
    }
  },
  data() {
    return {
      title: this.$t('dynamic.operation'),
      width: '1600px',
      moreStatus: false,
      // 新增时子表默认添加几行空数据
      addDefaultRowNum: 1,
      visible: false,
      operTimeStr: '',
      prefixNo: 'XSDD',
      fileList: [],
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 8}
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16}
      },
      refKeys: ['materialDataTable'],
      activeKey: 'materialDataTable',
      materialTable: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: this.$t('search.depotName'),
            key: 'depotId',
            width: '7%',
            type: FormTypes.select,
            placeholder: '请选择${title}',
            options: [],
            allowSearch: true,
            validateRules: [{required: true, message: '${title}不能为空'}]
          },
          {title: '', key: 'hiddenKey', width: '1%', type: FormTypes.hidden},
          {
            title: this.$t('search.barCode'),
            key: 'barCode',
            width: '12%',
            type: FormTypes.popupJsh,
            kind: 'material',
            multi: true,
            validateRules: [{required: true, message: '${title}不能为空'}]
          },
          { title: this.$t('search.name'), key: 'name', width: '10%', type: FormTypes.normal },
          { title: this.$t('search.standard'), key: 'standard', width: '8%', type: FormTypes.normal },
          { title: this.$t('search.model'), key: 'model', width: '8%', type: FormTypes.normal },
          { title: this.$t('search.color'), key: 'color', width: '5%', type: FormTypes.normal },
          { title: this.$t('search.materialOther'), key: 'materialOther', width: '5%', type: FormTypes.normal },
          { title: this.$t('search.stock'), key: 'stock', width: '5%', type: FormTypes.normal },
          { title: this.$t('search.unit'), key: 'unit', width: '4%', type: FormTypes.normal },
          { title: this.$t('search.sku'), key: 'sku', width: '4%', type: FormTypes.normal },
          {
            title: this.$t('search.quantity'),
            key: 'operNumber',
            width: '4%',
            type: FormTypes.inputNumber,
            statistics: true,
            validateRules: [{required: true, message: '${title}不能为空'}]
          },
          {title: this.$t('search.unitPrice'), key: 'unitPrice', width: '6%', type: FormTypes.inputNumber},
          {
            title: this.$t('search.allPrice'),
            key: 'allPrice',
            width: '9%',
            type: FormTypes.inputNumber,
            statistics: true
          },
          // {
          //   title: this.$t('search.taxRate1'),
          //   key: 'taxRate',
          //   width: '4%',
          //   type: FormTypes.inputNumber,
          //   placeholder: '%'
          // },
          // {
          //   title: this.$t('search.taxMoney'),
          //   key: 'taxMoney',
          //   width: '4%',
          //   type: FormTypes.inputNumber,
          //   readonly: true,
          //   statistics: true
          // },
          // {
          //   title: this.$t('search.taxLastMoney'),
          //   key: 'taxLastMoney',
          //   width: '7%',
          //   type: FormTypes.inputNumber,
          //   statistics: true
          // },
          {
            title: this.$t('search.discount'),
            key: 'discount',
            width: '4%',
            type: FormTypes.inputNumber,
            placeholder: '%'
          },
          {
            title: this.$t('search.afterDiscount'),
            key: 'discountMoney',
            width: '5%',
            type: FormTypes.inputNumber,
            statistics: true
          },
          { title: this.$t('search.remark'), key: 'remark', width: '6%', type: FormTypes.input }
        ]
      },
      confirmLoading: false,
      validatorRules: {
        operTime: {
          rules: [
            { required: true, message: this.$t('placeholder.pleaseInputBillDate') }
          ]
        },
        organId: {
          rules: [
            { required: true, message: this.$t('message.pleaseSelectCustomer') }
          ]
        }
      },
      url: {
        add: '/depotHead/addDepotHeadAndDetail',
        edit: '/depotHead/updateDepotHeadAndDetail',
        detailList: '/depotItem/getDetailList'
      }
    }
  },
  created() {
  },
  methods: {
    //调用完edit()方法之后会自动调用此方法
    editAfter() {
      this.billStatus = 0
      this.currentSelectDepotId = ''
      this.changeColumnHide()
      if (this.action === 'add') {
        this.addInit(this.prefixNo)
        this.personList.value = ''
        this.payTypeList.value = ''
        this.fileList = []
        this.$nextTick(() => {
          handleIntroJs(this.prefixNo, 1)
        })
      } else {
        this.model.operTime = this.model.operTimeStr
        if (this.model.accountId == null && this.model.accountIdList) {
          this.model.accountId = 0
          this.manyAccountBtnStatus = true
          this.accountIdList = this.model.accountIdList
          this.accountMoneyList = this.model.accountMoneyList
        } else {
          this.manyAccountBtnStatus = false
        }
        // Set payTypeList.value as string to match option values
        this.payTypeList.value = this.model.payType != null ? String(this.model.payType) : ''
        this.personList.value = this.model.salesMan
        this.fileList = this.model.fileName

        this.$nextTick(() => {
          // Set form fields, including payType as string to match select options
          this.form.setFieldsValue(pick(this.model,
            'organId', 'operTime', 'number', 'remark', 'pono', 'taxMoney', 'taxValue',
            'discount', 'discountMoney', 'discountLastMoney',
            'accountId', 'changeAmount', 'salesMan'
          ))

          // Explicitly set payType field in form
          if (this.model.payType != null) {
            this.form.setFieldsValue({payType: String(this.model.payType)})
          }
        })
        // 加载子表数据
        let params = {
          headerId: this.model.id,
          mpList: getMpListShort(Vue.ls.get('materialPropertyList')),  //扩展属性
          linkType: 'basic'
        }
        let url = this.readOnly ? this.url.detailList : this.url.detailList
        this.requestSubTableData(url, params, this.materialTable)
      }
      //复制新增单据-初始化单号和日期
      if (this.action === 'copyAdd') {
        this.model.id = ''
        this.model.tenantId = ''
        this.copyAddInit(this.prefixNo)
      }
      this.initSystemConfig()
      this.initCustomer(0)
      this.initSalesman()
      this.initDepot()
      this.initAccount(0)
      this.initPlatform()
      this.initPayType()
    },
    //提交单据时整理成formData
    classifyIntoFormData(allValues) {
      let totalPrice = 0
      let billMain = Object.assign(this.model, allValues.formValue)
      let detailArr = allValues.tablesValue[0].values
      billMain.type = '其它'
      billMain.subType = '销售订单'
      for (let item of detailArr) {
        totalPrice += item.allPrice - 0
      }
      billMain.totalPrice = totalPrice
      if (billMain.accountId === 0) {
        billMain.accountId = ''
      }
      billMain.accountIdList = this.accountIdList.length > 0 ? JSON.stringify(this.accountIdList) : ''
      billMain.accountMoneyList = this.accountMoneyList.length > 0 ? JSON.stringify(this.accountMoneyList) : ''
      if (this.fileList && this.fileList.length > 0) {
        billMain.fileName = this.fileList
      } else {
        billMain.fileName = ''
      }
      if (this.model.id) {
        billMain.id = this.model.id
      }
      // 确保payType是数字类型发送到服务器
      billMain.payType = this.payTypeList.value !== '' && this.payTypeList.value != null ? Number(this.payTypeList.value) : undefined
      billMain.salesMan = this.personList.value
      billMain.status = this.billStatus
      return {
        info: JSON.stringify(billMain),
        rows: JSON.stringify(detailArr)
      }
    },
    handleHistoryBillList() {
      let organId = this.form.getFieldValue('organId')
      this.$refs.historyBillListModalForm.show('其它', '销售订单', '客户', organId)
      this.$refs.historyBillListModalForm.disableSubmit = false
    },
    onSearchLinkNumber() {
      this.$refs.linkBillList.show('其它', '采购订单', '客户', '2')
      this.$refs.linkBillList.title = this.$t('title.selectPurchaseOrder')
    },
    linkBillListOk(selectBillDetailRows, linkNumber, organId, discountMoney, deposit, remark, depotId) {
      let that = this
      console.log(selectBillDetailRows)
      console.log(linkNumber)

      this.materialTable.columns[1].type = FormTypes.normal
      this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
      this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
      if (selectBillDetailRows && selectBillDetailRows.length > 0) {
        let listEx = []
        let discountLastMoney = 0
        for (let j = 0; j < selectBillDetailRows.length; j++) {
          let info = selectBillDetailRows[j]
          if (info.finishNumber > 0) {
            info.operNumber = info.preNumber
            info.allPrice = info.operNumber * info.unitPrice - 0
            //   let taxRate = info.taxRate - 0
            //   info.taxMoney = (info.allPrice * taxRate / 100).toFixed(2) - 0
            //   info.taxLastMoney = (info.allPrice + info.taxMoney).toFixed(2) - 0
          }
          info.linkId = info.id
          discountLastMoney += info.taxLastMoney
          listEx.push(info)
          this.changeColumnShow(info)
        }
        this.$nextTick(() => {
          this.form.setFieldsValue({
            'discountLastMoney': discountLastMoney,
            'remark': remark
          })
        })
        //判断后进行仓库的切换
        if (depotId) {
          setTimeout(function () {
            that.batchSetDepotModalFormOk(depotId)
          }, 1000)
        }
      }
      this.materialTable.dataSource = selectBillDetailRows
    },
    initPayType() {
      this.payTypeList.options = [{'text': this.$t('status.cash'), 'value': '1'}, {
        'text': this.$t('status.credit'),
        'value': '2'
      }]
    }
  }
}
</script>
<style scoped>

</style>